/*
 * @Description: 检测模板相关接口
 * @Author: Zzt
 * @Date: 2022-10-17 11:02:14
 * @LastEditTime: 2023-02-10 16:26:35
 */
import request from '@/utils/request';
import type { IPageQuery } from '@/interfaces/global';
import { IFetchDetectionListByPageParams } from './detectionPlan';

export interface IAddDetectionTemplateParams {
  archiveTypeId: number;
  detectionType: number;
  schemeIdList?: SchemeIDList[];
  templateName?: string;
}
export interface SchemeIDList {
  schemeId: number;
  sortNo: number;
}

// 新增检测模板
export function addDetectionTemplate(data: IAddDetectionTemplateParams) {
  return request({
    url: `/archive-detection-template/`,
    method: 'post',
    data
  });
}
export interface IDetectionTemplateListParams extends IFetchDetectionListByPageParams {
  detectionType?: number;
}
// 查询模板列表
export function detectionTemplateList(data: IDetectionTemplateListParams) {
  return request({
    url: '/archive-detection-template/list/',
    method: 'post',
    data
  });
}

export interface IDetectionTemplateByPageParams {
  archiveTypeId?: number;
  createTime?: string;
  detectionType?: number;
  id?: number;
  operator?: number;
  operatorName?: string;
  operatorTime?: string;
  remark?: string;
  templateDesc?: string;
  templateName?: string;
}
// 分页查询列表
export function detectionTemplateByPage(data: IPageQuery<IDetectionTemplateByPageParams>) {
  return request({
    url: '/archive-detection-template/page/',
    method: 'post',
    data
  });
}

// 根据Id查询检测模板
export function findDetectionTemplate(id: number) {
  return request({
    url: `/archive-detection-template/${id}`,
    method: 'get'
  });
}
// 根据Id删除检测模板
export function deleteDetectionTemplate(id: number | string) {
  return request({
    url: `/archive-detection-template/${id}`,
    method: 'delete'
  });
}
// 通过id修改检测模板
export interface IediteDetectionTemplateParams extends IAddDetectionTemplateParams {
  id: number;
}
export function editeDetectionTemplate(data: IediteDetectionTemplateParams) {
  return request({
    url: '/archive-detection-template/',
    method: 'put',
    data
  });
}
